package com.ljkj.lawyer.lawyer.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class RestResult {
    private int code;
    private String message;
    private Object data;

    public static RestResult success(Object data){
        return new RestResult(ErrorCodeNum.SUCCESS.getCode(), ErrorCodeNum.SUCCESS.getMsg(),data);
    }

    public static RestResult success(){
        return new RestResult(ErrorCodeNum.SUCCESS.getCode(), ErrorCodeNum.SUCCESS.getMsg(),null);
    }

    public static RestResult error(){
        return new RestResult(ErrorCodeNum.FAIL.getCode(), ErrorCodeNum.FAIL.getMsg(),null);
    }

    public static RestResult error(String message){
        return new RestResult(ErrorCodeNum.FAIL.getCode(),message,null);
    }

    public static RestResult build(ErrorCodeNum errorCode){
        return new RestResult(errorCode.getCode(),errorCode.getMsg(),null);
    }

    public static RestResult noLogin(){
        return new RestResult(ErrorCodeNum.NO_LOGIN.getCode(), ErrorCodeNum.NO_LOGIN.getMsg(),null);
    }
}

